<template>
  <div class="rank">
    <h4 class="title">{{ title }}</h4>
    <ul class="list">
      <li :key="index" v-for="(item, index) in list">
        <span :class="index < 3 ? 'active' : null">{{ index + 1 }}</span>
        <span class="title2">
          <a class="textname">{{ item.name }}</a>
        </span>
        <span class="right">{{ item.total }}</span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'RankList',
  // ['title', 'list']
  props: {
    title: {
      type: String,
      default: ''
    },
    list: {
      type: Array,
      default: null
    }
  }
}
</script>

<style lang="less" scoped>
  .rank {
    padding: 0 32px 32px 72px;

    .list {
      margin: 25px 0 0;
      padding: 0;
      list-style: none;

      li {
        width: 100%;
        display: inline-block;
        overflow: hidden;

        span {
          color: rgba(0, 0, 0, .65);
          font-size: 14px;
          line-height: 22px;

          &:first-child {
            background-color: #f5f5f5;
            border-radius: 20px;
            display: inline-block;
            font-size: 12px;
            font-weight: 600;
            margin-right: 24px;
            height: 20px;
            line-height: 20px;
            width: 20px;
            text-align: center;
          }

          &.active {
            background-color: #314659;
            color: #fff;
          }

          &:last-child {
            float: right;
          }
        }

        .title2 {
          display: inline-block;
          width: 80%;
          font-size: 14px;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          line-height: 22px;

          .textname {
            overflow: hidden;
            width: 80%;
            line-height: 22px;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }

        .right {
          float: right;
        }
      }

    }
  }

  @media screen and (min-width:1206px) and (max-width:1770px) {
    .rank {
      .title2 {
        width: 60%!important;
        .textname {
          width: 60%!important;
        }
      }
    }
  }
  @media screen and (min-width:760px) and (max-width:990px) {
    .rank {
      .title2 {
        width: 50%!important;
        .textname {
          width: 50%!important;
        }
      }
    }
  }

  .mobile .rank {
    padding: 0 32px 32px 32px;
  }
</style>
